package my.algorithms.mcorrea.topcoder;

/**
 * http://community.topcoder.com/stat?c=problem_statement&pm=407
 * You will be given an input of three int[].  The first int[] consists of easy
problem times, the second consists of middle problem times, and the third
consists of hard problem times.  Return the number of legal problem set
combinations, where a legal set contains exactly 1 easy, 1 middle and 1 hard
problem, and the total time is between 60 and 75 inclusive.
 * @author mcorrea
 */
public class Chooser {

    public static void main(String[] args) {
		int[] easy = {5,10,15};
		int[] medium = {15,25};
		int[] hard = {45};
		System.out.println(numSets(easy, medium, hard));
		
		int[] easy1 = {5,5,5};
		int[] medium1 = {15,15,15};
		int[] hard1 = {45,45,35};
		System.out.println(numSets(easy1, medium1, hard1));
    }
	
	public static int numSets(int[] easy, int[] middle, int[] hard){
		
		int count = 0;
		for(int e: easy){
			for(int m: middle){
				for(int h: hard){
					int time = e+m+h; 
					//System.out.println( e+"+"+m+"+"+h+"="+time  );
					if( time >=60 && time<=75  ){
						count++;
					}
				}
			}
		}
		return count;
	}

}
